package com.itheima.Controller;

import com.itheima.Service.UserService;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Result;
import com.itheima.pojo.Role;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/api/roles")
public class RoleController {
    @Autowired
    private UserService userService;

    /*查询角色数据*/
    @GetMapping
    private Result getCharacter() {
        log.info("查询角色数据");
        List<Role> roles = userService.getRoles();
        return Result.success(roles);
    }
    /*查询角色详情权限*/
    @GetMapping("/details/{id}")
    private Result getCharacterDetails(@PathVariable int id){
        log.info("查询角色数据详情,{}",id);
        List<Permission> permissions = userService.getPersmissions(id);
        return Result.success(permissions);
    }
}
